home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crosscountry USA Photo Safari
/
Crosscountry USA Photo Safari.iso
/
Data
/
cc_base
/
pak00_16bit_f.pk3
/
common
/
calc_accident.c4
next >
Wrap
Text File
|
2002-11-29
|
5KB
|
150 lines
{
@calc_accident {
resid Player;
resid Game;
str accident_message;
int player_fatigue;
int player_hunger;
int fatigue_threshold;
int hunger_threshold;
int score;
int threshold;
int rain;
int snow;
int no_wipers;
int no_chains;
int night;
int no_headlights;
int fatigued;
int starving;
int speeding;
int time_last_accident;
int time_now;
int time_between_accidents;
Game = ResByName("Game");
Player = ResPropGetResID(Game,"game_cur_player");
ResPropAlias( Player, "nav_accident_message", "accident_message");
ResPropAlias( Player,"time_last_accident","time_last_accident");
player_fatigue = ResPropGetInt(Player,"player_fatigue");
player_hunger = ResPropGetInt(Player,"player_hunger");
fatigue_threshold = ResPropGetInt(Game,"game_fatigue_threshold");
hunger_threshold = ResPropGetInt(Game,"game_hunger_threshold");
time_between_accidents = ResPropGetInt(Game, "game_time_between_accidents");
time_now = ResPropGetInt(Player,"time_now");
/* SCORES */
threshold = ResPropGetInt(Game,"game_accident_threshold");
rain = 5;
snow = 10;
no_wipers = 10;
no_chains = 5;
night = 5;
no_headlights = 10;
fatigued = 20;
starving = 20;
speeding = 10;
if ( (time_last_accident + time_between_accidents) > time_now ) {
stop;
}
accident_message = MangleSIDToStr(262/*"You had an accident because: "*/);
/* check if its raining */
if (StrExact(ResPropGetStr(Player,"weather_precip"),"r")) {
score += rain;
accident_message = StrCat(accident_message, MangleSIDToStr(263/*" it was raining,"*/));
/* check for wipers */
if (ResPropGetInt(Player,"truck_wiper")==0) {
accident_message = StrCat(accident_message, MangleSIDToStr(264/*" your wipers were off,"*/));
score += no_wipers;
}
}
/* check if its snowing*/
if (StrExact(ResPropGetStr(Player,"weather_precip"),"s")) {
score += snow;
accident_message = StrCat(accident_message, MangleSIDToStr(265/*" it was snowing,"*/));
/* check for wipers */
if (ResPropGetInt(Player,"truck_wiper")==0) {
score += no_wipers;
accident_message = StrCat(accident_message, MangleSIDToStr(266/*" your wipers were off,"*/));
}
/* check for chains */
if (ResPropGetInt(Player,"truck_chains_on")==0) {
accident_message = StrCat(accident_message, MangleSIDToStr(267/*" you did not have your chains on,"*/));
score += no_chains;
}
}
/* check for chains on pavement*/
if (StrExact(ResPropGetStr(Player,"weather_precip"),"d")) {
/* check for chains */
if (ResPropGetInt(Player,"truck_chains_on")==0) {
accident_message = StrCat(accident_message, MangleSIDToStr(268/*" you had your chains on,"*/));
score += no_chains;
}
}
/* check for speeding */
if (ResPropGetInt(Player,"truck_speeding")==1) {
accident_message = StrCat(accident_message, MangleSIDToStr(269/*" you were speeding,"*/));
score += speeding;
}
/* check if its night time */
if (StrExact(ResPropGetStr(Player,"weather_time_of_day"),"n")) {
score += night;
accident_message = StrCat(accident_message, MangleSIDToStr(270/*" it was night,"*/));
/* check for headlights */
if( ResPropGetInt(Player,"truck_light") == 0 ) {
accident_message = StrCat(accident_message, MangleSIDToStr(271/*" your lights were off,"*/));
score += no_headlights;
}
}
/* check for starving */
if (player_hunger >= hunger_threshold) {
accident_message = StrCat(accident_message, MangleSIDToStr(272/*" you were too hungry to concentrate,"*/));
score += starving;
}
/* check for falling asleep */
if (player_fatigue >= fatigue_threshold) {
accident_message = StrCat(accident_message, MangleSIDToStr(273/*" you were falling asleep,"*/));
score += fatigued;
}
/* break off comma */
accident_message = StrLeft(accident_message,(StrLen(accident_message)-1));
/* add period */
accident_message = StrCat(accident_message,".");
if (score >= threshold) {
CVarSetInt("guiInputEnabled",0);
ResPropSetInt( Player, "truck_broken", 1);
ResPropSetInt(ResByName("dash.gl/SegmentController"),"state",10);
ResParseEvent(ResByName("dash.gl/brake_pedal"),"@activate");
ResParseEvent(ResByName("dash.gl/ignition_switch"),"@activate");
time_last_accident = time_now;
}
LogStr(LOG_DEBUG,"\n\n\n\nACCIDENT SCORE: %d\n\n\n\n\n\n",score);
}
}